package com.example.springcloud.controller;

import com.example.api.dept.DeptApi;
import com.example.springcloud.common.ResponseEntity;
import com.example.springcloud.common.entity.Dept;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 莫磊
 * @date 2025/8/21
 * @description
 */
@RestController
@RequestMapping("/feign/dept")
public class DeptForFeignController {

    @Resource
    private DeptApi deptApi;

    @GetMapping("/getById/{id}")
    public ResponseEntity<Dept> getById(@PathVariable("id") Long id) {
        return deptApi.getById(id);
    }

    @PostMapping("/addDept")
    public ResponseEntity<Dept> addDept(Dept dept) {
        return deptApi.addDept(dept);
    }

    @GetMapping("/findByDnameLike/{dname}")
    public ResponseEntity<List<Dept>> findByDnameLike(@PathVariable("dname") String dname) {
        return deptApi.findByDnameLike(dname);
    }

    @GetMapping("/findByDeptno/{deptno}")
    public ResponseEntity<List<Dept>> findByDeptno(@PathVariable("deptno") String deptno) {
        return deptApi.findByDeptno(deptno);
    }
}
